<!-- Running a transform - adding a template that matches the book element and recreates catalog.xml file with an XHTML <a> link inside of it -->
<!-- Output the books according to prices in descending order-->
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
    <!--xsl:template match="*|@*|processing-instruction()">
        <xsl:copy>
            <xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
        </xsl:copy>
    </xsl:template-->
    
    <!--xsl:template match="book/title"--> <!-- Xpath used here is known as location path -->
    <!--title>
        <a xmlns="http://www.w3.org/1999/xhtml"
            href="{../@id}.xhtml">
            <xsl:value-of select="."/>
            </a>
    </title>
    </xsl:template-->
    <xsl:template  match="bookcatalog/book">
        <html>
            <head/>
            <body>
                <h3>
                    <ul><li>
                    <xsl:text>Publish Date from</xsl:text>
                    <xsl:value-of select="child::*[1]/publish_date"/>
                    <xsl:text>until</xsl:text>
                    <xsl:value-of select="child::*[last()]/publish_date"/>
                    <xsl:text></xsl:text>
                    </li></ul>
                </h3>
                <xsl:apply-templates select="price"/>
                <!-- Price Information -->
                <h3>
                    <xsl:text>Prices from</xsl:text>
                    <xsl:value-of select="child::*[1]/publish_date"/>
                    <xsl:text>until</xsl:text>
                    <xsl:value-of select="child::*[last()]/publish_date"/>
                    <xsl:text>highest to lowest</xsl:text>
                </h3>
                <xsl:apply-templates select="book">
                    <xsl:sort data-type="number" order="descending"
                    select="price"/>
                </xsl:apply-templates>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
